{% extends "base.html" %}

{% block title %}场景选择 - LandPPT{% endblock %}

{% block extra_css %}
<style>
/* 场景选择页面：轻盈渐变风 */
.scenarios-page {
    background: radial-gradient(circle at 12% 18%, rgba(59, 130, 246, 0.14), transparent 32%),
                radial-gradient(circle at 88% 12%, rgba(16, 185, 129, 0.12), transparent 28%),
                linear-gradient(180deg, #f8fafc 0%, #ffffff 22%, #f7f9fb 100%);
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
}

.scenarios-hero {
    background: linear-gradient(135deg, rgba(244, 246, 255, 0.95), rgba(233, 246, 255, 0.92));
    backdrop-filter: blur(22px);
    border: 1px solid rgba(17, 24, 39, 0.06);
    color: var(--text-primary);
    padding: calc(var(--spacing-lg) + 4px) var(--spacing-lg);
    margin: 0 0 var(--spacing-lg) 0;
    text-align: center;
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

.scenarios-hero::before,
.scenarios-hero::after {
    content: '';
    position: absolute;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.65;
}

.scenarios-hero::before {
    background: radial-gradient(circle, rgba(59, 130, 246, 0.28), transparent 60%);
    top: -120px;
    left: -80px;
}

.scenarios-hero::after {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.25), transparent 60%);
    bottom: -140px;
    right: -100px;
}

.scenarios-hero h2 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.01em;
    position: relative;
    z-index: 1;
    background: linear-gradient(120deg, #0f172a 0%, #0f4b8a 45%, #0b7665 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.scenarios-hero p {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 640px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    line-height: 1.6;
}

.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--spacing-md);
    margin: 0 auto var(--spacing-lg);
    max-width: 1200px;
}

.scenario-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 249, 252, 0.94));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(17, 24, 39, 0.05);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 18px 38px rgba(15, 23, 42, 0.08);
    overflow: hidden;
    transition: transform 0.35s ease, box-shadow 0.35s ease, border-color 0.35s ease;
    cursor: pointer;
    position: relative;
    height: fit-content;
}

.scenario-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(59, 130, 246, 0.08), transparent 45%),
                radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.08), transparent 45%);
    opacity: 0;
    transition: opacity 0.35s ease;
}

.scenario-card:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 26px 60px rgba(15, 23, 42, 0.16);
    border-color: rgba(59, 130, 246, 0.25);
}

.scenario-card:hover::before {
    opacity: 1;
}

.scenario-card-body {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: var(--spacing-lg) var(--spacing-md) calc(var(--spacing-lg) - 4px);
}

.scenario-title {
    color: var(--text-primary);
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
    line-height: 1.3;
    letter-spacing: -0.005em;
}

.scenario-description {
    color: #5f6c80;
    line-height: 1.6;
    margin: 0 auto var(--spacing-lg);
    font-size: 0.95rem;
    max-width: 320px;
    line-clamp: 2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.scenario-button {
    background: linear-gradient(120deg, #0f172a 0%, #111827 40%, #0b4f81 100%);
    color: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.12);
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.95rem;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-xs);
    min-width: 160px;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.16);
}

.scenario-button:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.18);
    filter: brightness(1.02);
}

.scenario-button:focus-visible {
    outline: 2px solid rgba(59, 130, 246, 0.6);
    outline-offset: 3px;
}

/* 响应式 */
@media (max-width: 1024px) {
    .scenarios-hero {
        padding: var(--spacing-lg) var(--spacing-md);
    }

    .scenarios-hero h2 {
        font-size: 2rem;
    }
}

@media (max-width: 768px) {
    .scenarios-page {
        padding: var(--spacing-md);
    }

    .scenarios-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: var(--spacing-sm);
    }

    .scenarios-hero {
        margin-bottom: var(--spacing-md);
    }

    .scenarios-hero h2 {
        font-size: 1.85rem;
    }

    .scenarios-hero p {
        font-size: 0.95rem;
    }

    .scenario-card-body {
        padding: var(--spacing-md) var(--spacing-sm) var(--spacing-md);
    }

    .scenario-title {
        font-size: 1.05rem;
    }

    .scenario-description {
        font-size: 0.88rem;
        margin-bottom: var(--spacing-md);
    }

    .scenario-button {
        padding: var(--spacing-xs) var(--spacing-md);
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .scenarios-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-xs);
    }

    .scenario-card {
        border-radius: var(--border-radius-md);
    }

    .scenario-title {
        font-size: 0.98rem;
    }

    .scenario-description {
        font-size: 0.8rem;
    }

    .scenario-button {
        min-width: 140px;
        font-size: 0.84rem;
    }
}
</style>
{% endblock %}

{% block content %}
<div class="scenarios-page">
    <div class="scenarios-hero">
        <h2>选择 PPT 场景</h2>
        <p>选择最适合您需求的场景模板，AI 将根据场景特点生成专业的 PPT</p>
    </div>

    <div class="scenarios-grid">
        {% for scenario in scenarios %}
        <div class="scenario-card" onclick="selectScenario('{{ scenario.id }}', '{{ scenario.name }}')">
            <div class="scenario-card-body">
                <h3 class="scenario-title">{{ scenario.name }}</h3>
                <p class="scenario-description">{{ scenario.description }}</p>
                <button class="scenario-button" onclick="event.stopPropagation(); selectScenario('{{ scenario.id }}', '{{ scenario.name }}')">
                    选择此场景
                </button>
            </div>
        </div>
        {% endfor %}
    </div>
</div>

<!-- PPT Generation Form Modal -->
<div id="generationModal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; backdrop-filter: blur(6px);">
    <div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(255,255,255,0.96); padding: 40px; border-radius: 20px; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 26px 60px rgba(15, 23, 42, 0.22); border: 1px solid rgba(17,17,17,0.1);">
        <h3 style="color: var(--text-primary); margin-bottom: 20px; text-align: center; font-weight: 600;">
            创建 <span id="selectedScenarioName" style="color: var(--surface-contrast);"></span> 项目
        </h3>
        
        <form action="/projects/create" method="post">
            <input type="hidden" id="scenarioInput" name="scenario" value="">
            
            <div class="form-group">
                <label for="topic">PPT 主题 *</label>
                <input type="text" id="topic" name="topic" required placeholder="例如：人工智能技术发展趋势">
            </div>
            
            <div class="form-group">
                <label for="requirements">具体要求</label>
                <textarea id="requirements" name="requirements" rows="4" placeholder="请描述您的具体要求，如重点内容、风格偏好等..."></textarea>
            </div>
            
            <div class="form-group">
                <label for="language">语言</label>
                <select id="language" name="language">
                    <option value="zh">中文</option>
                    <option value="en">English</option>
                </select>
            </div>
            
            <div class="form-group">
                <label style="display: flex; align-items: center; cursor: pointer;">
                    <input type="checkbox" id="network_mode" name="network_mode" style="margin-right: 10px; width: auto;">
                    <span style="display: flex; flex-direction: column;">
                        <span>启用 Research 联网模式</span>
                        <small style="color: var(--text-muted); margin-top: 5px;">
                            使用AI进行联网搜索，获取权威信息源，生成研究报告并保存到本地
                        </small>
                    </span>
                </label>
            </div>
            
            <div style="text-align: center; margin-top: 30px;">
                <button type="button" onclick="closeModal()" class="btn btn-secondary" style="margin-right: 10px;">取消</button>
                <button type="submit" class="btn btn-primary">创建项目</button>
            </div>
        </form>
    </div>
</div>


{% endblock %}

{% block extra_js %}
<script>
function selectScenario(scenarioId, scenarioName) {
    document.getElementById('scenarioInput').value = scenarioId;
    document.getElementById('selectedScenarioName').textContent = scenarioName;
    document.getElementById('generationModal').style.display = 'block';
    
    // Set focus to topic input
    setTimeout(() => {
        document.getElementById('topic').focus();
    }, 100);
}

function closeModal() {
    document.getElementById('generationModal').style.display = 'none';
}

// Close modal when clicking outside
document.getElementById('generationModal').addEventListener('click', function(e) {
    if (e.target === this) {
        closeModal();
    }
});

// Close modal with Escape key
document.addEventListener('keydown', function(e) {
    if (e.key === 'Escape') {
        closeModal();
    }
});
</script>
{% endblock %}
